import { createVNode } from 'vue'
import { notification, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';

/**
 * 消息框帮助
 */
export class MessageBox {
    /**
     * 删除
     * @param title 显示的标题
     * @param content 显示的内容
     * @returns boolean类型
     */
    static async confirm(content: string = "确定要删除吗?", title: string = "提示"): Promise<boolean> {
        return new Promise((resolve) => {
            Modal.confirm({
                title: title,
                icon: createVNode(ExclamationCircleOutlined),
                content: content,
                onOk() {
                    resolve(true);
                },
                onCancel() {
                    resolve(false);
                }
            })
        });
    }

    /**
     * 是否返回到指定页面
     * @param content 
     * @param title 
     * @returns 
     */
    static async confirmGoPage(content: string = "是否返回列表?", title: string = "提示"): Promise<boolean> {
        return await this.confirm(content, title);
    }

    /**
     * 
     * @param content 
     * @param title 
     * @returns 
     */
    static async alert(content: string, title: string = "信息"): Promise<boolean> {
        return new Promise((resolve) => {
            Modal.info({
                title: title,
                content: content,
                onOk() {
                    resolve(true);
                },
                onCancel() {
                    resolve(false)
                }
            })
        })
    }
}